package com.xiaoyu.awakening.ai.index.service.impl;

import com.xiaoyu.awakening.ai.index.core.parse.AwkParseFactory;
import com.xiaoyu.awakening.ai.index.core.parse.AwkParseReq;
import com.xiaoyu.awakening.ai.index.core.parse.AwkParseRes;
import com.xiaoyu.awakening.ai.index.entity.AwkIndexPipelineContext;
import com.xiaoyu.awakening.ai.index.service.IAwkIndexDocumentService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 文档索引服务
 *
 * @author wangxiaoyu
 * @date 2025/7/9 16:21
 * @since v1.0
 */
@Service
public class AwkIndexDocumentServiceImpl implements IAwkIndexDocumentService {
    @Resource
    private AwkParseFactory awkParseFactory;

    @Override
    public Boolean indexDocumentPipeline(AwkIndexPipelineContext context) {

        // parse extract text
        AwkParseReq awkParseReq = AwkParseReq.builder()
                .fileName(context.getFileName())
                .downloadUrl(context.getDownloadUrl())
                .build();
        AwkParseRes awkParseRes = awkParseFactory.parse(awkParseReq);

        // extract metadata
        if (context.getAutoExtractMetadata()) {
            // extract metadata
        }

        // split
        if (context.getAutoChooseChunkSplitter()) {
            // choose chunk splitter
        }

        // index
        if (context.getAutoSaveDb()) {
            // save db
        }

        return Boolean.TRUE;
    }
    
    public Boolean index(AwkIndexPipelineContext context) {
        return null;
    }
}
